:root {
  color-scheme: light;
  --page: #f4f1ea;
  --panel: #fbfaf7;
  --card: #ffffff;
  --text: #1f2622;
  --muted: #69736d;
  --line: #deddd7;
  --line-strong: #c7c9c3;
  --accent: #146c5a;
  --accent-ink: #ffffff;
  --accent-soft: #e4f0ec;
  --danger: #a1463b;
  --shadow: 0 18px 50px rgba(37, 45, 40, 0.12);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #171b18;
    --panel: #1d221f;
    --card: #242a26;
    --text: #edf1ed;
    --muted: #a9b2ac;
    --line: #343c37;
    --line-strong: #4b554f;
    --accent: #70c7ad;
    --accent-ink: #10251e;
    --accent-soft: #233d34;
    --danger: #ef988b;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--page);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  overflow: hidden;
}

button, input { font: inherit; }

button, a { -webkit-tap-highlight-color: transparent; }

button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 38%, transparent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
}

.catalog {
  display: flex;
  min-height: 0;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
  z-index: 3;
}

.catalog-header {
  flex: 0 0 auto;
  padding: 24px 22px 14px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 3px;
}

.map-source-badge {
  align-self: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.4rem 0.7rem;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin-bottom: 0;
  font-size: clamp(25px, 3vw, 32px);
  line-height: 1.05;
  letter-spacing: -0.045em;
}

h2 {
  margin: 2px 0 0;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: -0.035em;
}

h3 {
  margin-bottom: 7px;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.intro {
  max-width: 350px;
  margin: 12px 0 17px;
  color: var(--muted);
  font-size: 13px;
}

.quiet-button, .filter-chip, .detail-close {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.quiet-button {
  flex: none;
  padding: 7px 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.quiet-button:hover, .text-link:hover { text-decoration: underline; }

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 11px 0 14px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

.search-box:focus-within { border-color: var(--accent); }

.search-box input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.search-box input::placeholder { color: var(--muted); }

kbd {
  min-width: 24px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-bottom-color: var(--line-strong);
  border-radius: 5px;
  color: var(--muted);
  font: 11px/1.4 var(--font);
  text-align: center;
}

.filter-strip {
  display: flex;
  gap: 7px;
  margin: 13px -22px 0;
  padding: 0 22px 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filter-strip::-webkit-scrollbar { display: none; }

.filter-chip {
  flex: none;
  min-height: 32px;
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.filter-chip:hover { border-color: var(--line-strong); color: var(--text); }

.filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.list-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-top: 13px;
  color: var(--muted);
  font-size: 12px;
}

.toolbar-toggles {
  display: grid;
  gap: 5px;
}

.priority-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.priority-toggle input { accent-color: var(--accent); }

.place-list {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--line-strong) transparent;
}

.place-item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  padding: 15px 20px 15px 17px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background-color 140ms ease;
}

.place-item:hover, .place-item.selected { background: var(--accent-soft); }

.place-item.visited {
  background: color-mix(in srgb, var(--line) 28%, transparent);
  color: var(--muted);
}

.place-item.visited:hover, .place-item.visited.selected { background: color-mix(in srgb, var(--line) 54%, transparent); }

.place-item.visited .place-number {
  background: var(--line);
  border-color: var(--line);
  color: var(--muted);
}

.place-number {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.place-item.selected .place-number {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.place-title {
  display: -webkit-box;
  margin: 0 0 5px;
  overflow: hidden;
  font-size: 14px;
  font-weight: 735;
  line-height: 1.32;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.place-summary {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.place-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}

.tag {
  padding: 2px 7px;
  background: color-mix(in srgb, var(--line) 55%, transparent);
  border-radius: 999px;
}

.tag.feedback-delete { background: #f7dfdd; color: #8d2f27; }
.tag.feedback-review { background: #fff0c9; color: #755514; }

.pin-state { color: var(--accent); font-weight: 690; }
.pin-state.needs-check { color: var(--danger); }

.map-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #e7e7df;
}

.map-canvas { width: 100%; height: 100%; }

.map-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background-color: var(--page);
  z-index: 1200;
}

.map-placeholder[hidden] { display: none; }

.placeholder-card, .state-card {
  width: min(420px, 100%);
  padding: 24px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}

.placeholder-card strong, .state-card strong { display: block; font-size: 16px; }
.placeholder-card p, .state-card p { margin: 8px 0 18px; color: var(--muted); font-size: 13px; }

.status-dot {
  display: block;
  width: 10px;
  height: 10px;
  margin-bottom: 14px;
  background: var(--accent);
  border-radius: 50%;
}

.primary-button {
  min-height: 42px;
  padding: 9px 15px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  font-weight: 720;
}

.primary-button:hover { filter: brightness(0.96); }

.map-status {
  position: absolute;
  top: 18px;
  left: 50%;
  max-width: calc(100% - 36px);
  padding: 8px 12px;
  transform: translateX(-50%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  color: var(--muted);
  font-size: 12px;
  z-index: 1100;
}

.detail-card {
  position: absolute;
  right: 20px;
  bottom: 20px;
  width: min(440px, calc(100% - 40px));
  max-height: min(70dvh, 660px);
  padding: 22px;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  z-index: 1200;
}

.detail-card[hidden] { display: none; }

.detail-card h3, .detail-actions > * { overflow-wrap: anywhere; }

.place-gallery {
  position: relative;
  margin: -22px -22px 18px;
  overflow: hidden;
  background: #17201c;
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.gallery-track {
  display: flex;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.gallery-track::-webkit-scrollbar { display: none; }

.gallery-track img {
  display: block;
  width: 100%;
  height: 230px;
  flex: 0 0 100%;
  object-fit: cover;
  scroll-snap-align: start;
  user-select: none;
}

.gallery-arrow {
  position: absolute;
  top: 50%;
  display: grid;
  width: 38px;
  height: 38px;
  transform: translateY(-50%);
  place-items: center;
  background: rgba(20, 28, 24, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  font-size: 27px;
  line-height: 1;
  z-index: 2;
}

.gallery-arrow.previous { left: 10px; }
.gallery-arrow.next { right: 10px; }

.gallery-count {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 8px;
  background: rgba(20, 28, 24, 0.8);
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  font-weight: 720;
}

.gallery-credits {
  position: absolute;
  right: 8px;
  bottom: 8px;
  left: 8px;
  display: flex;
  max-width: calc(100% - 16px);
  gap: 8px;
  pointer-events: none;
}

.gallery-credits a {
  overflow: hidden;
  padding: 3px 6px;
  background: rgba(20, 28, 24, 0.82);
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 9px;
  pointer-events: auto;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-close {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
}

.detail-card > .detail-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
  z-index: 5;
}
.detail-close:hover { background: var(--accent-soft); }

.detail-kicker { margin-bottom: 7px; color: var(--accent); font-size: 12px; font-weight: 730; }
.detail-location { margin-bottom: 15px; color: var(--muted); font-size: 13px; }

.detail-section {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

.detail-section strong { display: block; margin-bottom: 5px; font-size: 12px; }
.detail-section p { margin: 0; color: var(--muted); font-size: 13px; }

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.feedback-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}

.feedback-button {
  min-height: 40px;
  padding: 9px 12px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  font: 700 12px/1.2 var(--font);
}

.feedback-button.delete:hover,
.feedback-button.delete.active { background: #f7dfdd; border-color: #d99d96; color: #8d2f27; }
.feedback-button.review:hover,
.feedback-button.review.active { background: #fff0c9; border-color: #e2c36e; color: #755514; }

.secondary-button, .source-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12px;
  font-weight: 690;
  text-decoration: none;
}

.secondary-button:hover, .source-link:hover { border-color: var(--accent); color: var(--accent); }

.marker-pin {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  background: #1d2823;
  border: 2px solid #ffffff;
  border-radius: 50% 50% 50% 7px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  color: #ffffff;
  font: 700 10px/1 var(--font);
  transform: rotate(-45deg);
}

.marker-pin span { transform: rotate(45deg); }
.marker-pin.active { background: #146c5a; transform: rotate(-45deg) scale(1.14); }
.marker-pin.visited { background: #848d87; opacity: 0.82; }
.marker-pin.visited.active { background: #146c5a; opacity: 1; }
.marker-pin.hotel { background: #f4c84a; border-color: #fff7d7; color: #382f16; box-shadow: 0 4px 18px rgba(122, 88, 0, 0.42); }
.marker-pin.hotel.active { background: #ffdb69; transform: rotate(-45deg) scale(1.2); }

.trip-marker {
  background: transparent;
  border: 0;
}

.leaflet-control-zoom a {
  color: #183a32;
}

.leaflet-control-attribution {
  font-size: 10px;
}

.visit-button.visited {
  background: var(--line);
  border-color: var(--line-strong);
  color: var(--text);
}

.settings-dialog {
  width: min(560px, calc(100% - 28px));
  padding: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  color: var(--text);
  box-shadow: var(--shadow);
}

.settings-dialog::backdrop { background: rgba(10, 18, 14, 0.56); }
.settings-dialog form { padding: 24px; }

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.settings-dialog > form > p { color: var(--muted); font-size: 13px; }

.field { display: block; margin-top: 15px; }
.field span { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 700; }
.field input {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
}

.field input:focus { border-color: var(--accent); outline: 0; }

.dialog-note {
  margin-top: 16px;
  padding: 12px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 12px;
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 20px;
}

.text-link { color: var(--accent); font-size: 12px; font-weight: 700; text-decoration: none; }

.state-card {
  margin: 24px auto;
  box-shadow: none;
  text-align: center;
}

.state-card p { margin-bottom: 0; }

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  margin-bottom: 12px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

@media (max-width: 760px) {
  html, body { overflow-x: hidden; }
  body { overflow-y: auto; }

  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 52dvh 48dvh;
    min-height: 100dvh;
    max-width: 100%;
    overflow: hidden;
  }

  .map-panel { grid-row: 1; }
  .map-panel, .catalog { width: 100%; min-width: 0; }
  .catalog { grid-row: 2; border-top: 1px solid var(--line); border-right: 0; }
  .catalog-header { padding: 16px 16px 11px; }
  .eyebrow, .intro, kbd { display: none; }
  h1 { font-size: 24px; }
  .title-row { margin-bottom: 12px; }
  .filter-strip { margin-right: -16px; margin-left: -16px; padding-right: 16px; padding-left: 16px; }
  .list-toolbar { margin-top: 10px; }
  .place-item { padding: 13px 16px; }
  .map-status { top: 10px; }

  .detail-card {
    right: 10px;
    bottom: 10px;
    width: calc(100% - 20px);
    max-height: calc(100% - 20px);
    padding: 18px;
  }

  .place-gallery { margin: -18px -18px 16px; }
  .gallery-track img { height: 190px; }

  .placeholder-card { padding: 18px; }
  .map-placeholder .placeholder-card { width: 100%; }
  .dialog-actions { align-items: stretch; flex-direction: column; }
  .dialog-actions .primary-button { width: 100%; }
}

@media (max-width: 390px) {
  .priority-toggle span { max-width: 118px; line-height: 1.15; }
  .quiet-button { font-size: 11px; }
}
